package com.llamarun;

import com.llamarun.R;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.Button;
import android.util.Log;
import android.view.*;
import android.widget.Toast;

public class PauseActivity extends Activity{

	MediaPlayer mp;
	private static final String TAG = PauseActivity.class.getSimpleName();
	
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        Log.d(TAG, "onCreate");
	        setContentView(R.layout.pause);
	        
	     // MUSIC
	        mp = MediaPlayer.create(PauseActivity.this, R.raw.pause);

	        
	        
//	       final Button restartButton = (Button) findViewById(R.id.restartBtn);
//	        restartButton.setOnClickListener(new View.OnClickListener() {
//	            public void onClick(View view) {
//	            	Intent myIntent = new Intent();
//	            	startActivityForResult(myIntent, 0);
//	                finish();
//	            }
//	        });
//	        
//	        
//	        final Button playButton = (Button) findViewById(R.id.resumeGameBtn);
//	        playButton.set OnClickListener(new View.OnClickListener() {
//	            public void onClick(View view) {
//	            	finish();
//	            }
//	        });
//	        
//	        
//	        final Button mainButton = (Button) findViewById(R.id.mainMenuBtn);
//	        mainButton.setOnClickListener(new View.OnClickListener() {
//	            public void onClick(View view) {
//	            	Intent myIntent = new Intent(view.getContext(), LlamaRunActivity.class);
//	                startActivityForResult(myIntent, 0);
//	                finish();
//	            }
//	        });
	       
	    }
	 
	 @Override
	    protected void onDestroy()
	    {
	    	Log.d(TAG, "Destroying...");
	    	super.onDestroy();
	    }
	     
	    @Override
	    protected void onStop() 
	    {
	    	Log.d(TAG, "Stopping...");
	    	super.onStop();
	    }
	    @Override
	    protected void onRestart()
	    {
	    	Log.d(TAG, "restarting...");
	    	super.onRestart();
	    }
	    @Override
	    protected void onResume()
	    {
	    	Log.d(TAG, "resuming...");
	    	super.onResume();
	    	if(!mp.isPlaying()) {
	    		mp.start();
	    		mp.seekTo(20500);
	    	}
	    	
	    }
	    
	    @Override
	    protected void onPause() {
	    	super.onPause();
	    	if(mp.isPlaying()) mp.stop(); 
	    }
	 
	 public void clickHandler(View v){
		 
		 Intent i = new Intent();
		 
		 switch(v.getId()){
		 case R.id.resumeGameBtn:
			 Log.d(TAG, "clickHandler - resume");
			 i.putExtra("pause_command", 0);
			 break;
		 case R.id.restartBtn:
			 Log.d(TAG, "clickHandler - restart");
			 i.putExtra("pause_command", 1);
			 break;
		 case R.id.mainMenuBtn:
			 Log.d(TAG, "clickHandler - main");
			 i.putExtra("pause_command", 2);
			 break;
		 }
		 setResult(RESULT_OK, i);
		 finish();
	 }
	    
}
